home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / gcc / ixemlsdk.lha / include / user.h < prev    next >
C/C++ Source or Header  |  1996-03-13  |  9KB  |  281 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #ifndef _USER_H
  21. #define _USER_H
  22.  
  23. #include <sys/time.h>
  24. #include <sys/resource.h>
  25. #include <setjmp.h>
  26. #include <machine/reg.h>
  27.  
  28. /* internal structure used by malloc(), kmalloc() and friends */
  29. struct malloc_data {
  30.   struct MinList    md_list;
  31.   unsigned int        md_malloc_sbrk_used;
  32. };
  33.  
  34. /* internal structure used by the stackextend code */
  35. struct stackframe
  36. {
  37.   struct stackframe *next;    /* NULL if there is no next one */
  38.   void *savesp;            /* stored sp for next underlying stackframe */
  39.   void *upper;            /* end of this stackframe+1 */
  40. };
  41.  
  42.  
  43. /*
  44.  * One structure allocated per session.
  45.  */
  46. struct    session {
  47.     int    s_count;        /* ref cnt; pgrps in session */
  48.     struct    proc *s_leader;        /* session leader */
  49.     struct    vnode *s_ttyvp;        /* vnode of controlling terminal */
  50.     struct    tty *s_ttyp;        /* controlling terminal */
  51.     char    s_login[MAXLOGNAME];    /* setlogin() name */
  52. };
  53.  
  54. /*
  55.  * One structure allocated per process group.
  56.  */
  57. struct    pgrp {
  58.     struct    pgrp *pg_hforw;        /* forward link in hash bucket */
  59.     struct    proc *pg_mem;        /* pointer to pgrp members */
  60.     struct    session *pg_session;    /* pointer to session */
  61.     pid_t    pg_id;            /* pgrp id */
  62.     int    pg_jobc;        /* # procs qualifying pgrp for job control */
  63. };
  64.  
  65. /*
  66.  * Per process structure
  67.  */
  68.  
  69. struct user {
  70.     /* both a magic cookie and a way to get at the library base thru u */
  71.     struct ixemul_base    *u_ixbase;
  72.  
  73. /* 1.3 - signal management */
  74.     sig_t        u_signal[NSIG];        /* disposition of signals */
  75.     int        u_sigmask[NSIG];    /* signals to be blocked */
  76.     sigset_t    u_sigonstack;        /* signals to take on sigstack */
  77.     sigset_t    u_sigintr;        /* signals that interrupt syscalls */
  78.     sigset_t    u_oldmask;        /* saved mask from before sigpause */
  79.     struct    sigstack u_sigstack;    /* sp & on stack state variable */
  80. #define    u_onstack    u_sigstack.ss_onstack
  81. #define    u_sigsp        u_sigstack.ss_sp
  82.     int        u_sig;            /* for core dump/debugger XXX */
  83.     int        u_code;            /* for core dump/debugger XXX */
  84.     
  85.     int        p_flag;            /* process flags, as necessary.. */
  86.     char        p_stat;
  87.     int        p_xstat;        /* exit status */
  88.     char        p_cursig;
  89.     sigset_t    p_sig;            /* signals pending to this process */
  90.     sigset_t    p_sigmask;        /* current signal mask */
  91.     sigset_t    p_sigignore;        /* signals being ignored */
  92.     sigset_t    p_sigcatch;        /* signals being caught by user */
  93.  
  94.     caddr_t     p_wchan;        /* event process is awaiting */
  95.  
  96.  
  97. /* 1.4 - descriptor management (for shared library version) */
  98.     struct    file *u_ofile[NOFILE];    /* file structures for open files */
  99.     char    u_pofile[NOFILE];    /* per-process flags of open files */
  100.     int    u_lastfile;        /* high-water mark of u_ofile */
  101. #define    UF_EXCLOSE     0x1        /* auto-close on exec */
  102.     short    u_cmask;        /* mask for file creation */
  103.  
  104. /* 1.5 - timing and statistics */
  105.     struct    rusage u_ru;        /* stats for this proc */
  106.     struct    rusage u_cru;        /* sum of stats for reaped children */
  107.     struct    itimerval u_timer[3];
  108.     struct    timeval u_start;
  109.     short    u_acflag;
  110.  
  111.     struct uprof {            /* profile arguments */
  112.         short    *pr_base;    /* buffer base */
  113.         unsigned pr_size;    /* buffer size */
  114.         unsigned pr_off;    /* pc offset */
  115.         unsigned pr_scale;    /* pc scaling */
  116.     } u_prof;
  117.  
  118. /* 1.6 - resource controls */
  119.     struct    rlimit u_rlimit[RLIM_NLIMITS];
  120.  
  121. /* amiga specific stuff */
  122.     struct malloc_data    u_md;
  123.     
  124.     struct MsgPort        *u_sync_mp;    /* PA_SIGNAL message port */
  125.     struct timerequest     *u_time_req;
  126.     int            *u_errno;
  127.     BPTR            u_startup_cd;
  128.     
  129.     int            u_ringring;    /* used in sleep.c and usleep.c */
  130.  
  131.     char            ***u_environ;
  132.  
  133.     /* used to handle amigados signals. see SIGMSG  */
  134.         u_int            u_lastrcvsig;
  135.         char            u_sleep_sig;
  136.         
  137.         /* c-startup stuff */
  138.         jmp_buf            u_jmp_buf;
  139.         char             *u_argline;
  140.         u_int            u_arglinelen;
  141.         int            u_expand_cmd_line;
  142.  
  143.     struct atexit        *u_atexit;
  144.     
  145.     char            u_getenv_buf[255];
  146.     
  147.     UBYTE            u_otask_flags;
  148.     void            (*u_olaunch)();
  149.     APTR            u_otrap_code;
  150.     APTR            u_otrap_data;
  151.     struct Interrupt    u_itimerint;    /* 1 interrupt / task */
  152.  
  153.     int            p_pgrp;        /* process group */
  154.  
  155.     char            *u_strtok_last;    /* moved with 37.8 */
  156.     
  157.     /* vfork() support */
  158.     struct MinList        p_zombies;    /* list of death messages */
  159.     int            p_zombie_sig;    /* signal to set when a child died */
  160.     struct Process        *p_pptr;    /* parent */
  161.     struct Process        *p_opptr;    /* old parent (used in ptrace) */
  162.     struct Process        *p_cptr;    /* last recently created child */
  163.     struct Process        *p_osptr;    /* older sybling */
  164.     struct Process        *p_ysptr;    /* younger sybling */
  165.     struct vfork_msg    *p_vfork_msg;
  166.  
  167.     long            u_segs;        /* execve stores the SegList here */
  168.     void            (*u_oswitch)();
  169.     
  170.     /* stdio support comes here */
  171.     char            u_tmpnam_buf[MAXPATHLEN]; /* quite large.. */
  172. #include <glue.h>
  173.     struct glue        u_sglue;
  174.     /* the 3 `standard' FILE pointers (!) are here */
  175.     void            *u_sF[3];
  176.  
  177.     /* vfork() support #2 */
  178.     void            *u_save_sp;    /* when vfork'd, this is the `real' sp */
  179.     jmp_buf            u_vfork_frame;    /* for the parent in vfork () */
  180.     u_int            u_mini_stack[1000]; /* 4K stack while in vfork () */
  181.  
  182.     /* stack watcher. When usp < u_red_zone && ix.ix_watch_stack -> SIGSEGV */
  183.     void            *u_red_zone;
  184.  
  185.     /* base relative support. This even works for pure programs ! */
  186.     u_int            u_a4;
  187.     
  188.     /* currently there's just 1, meaning don't trace me */
  189.     u_int            u_trace_flags;
  190.     
  191.     /* this is for getmntinfo() */
  192.     struct statfs        *u_mntbuf;
  193.     int            u_mntsize;
  194.     long            u_bufsize;
  195.     
  196.     /* this is for SIGWINCH support. */
  197.     struct IOStdReq        *u_idev_req;
  198.     struct Window        *u_window;    /* the watched window */
  199.     struct Interrupt    u_idev_int;
  200.  
  201.     /* for `ps' (or dump as it's called for now.. ) */
  202.     char            *p_wmesg;
  203.     
  204.     /* new support for `real' process groups, control ttys etc.. */
  205.     struct user        *p_pgrpnxt;
  206.     struct pgrp        *p_pgrpptr;
  207.     struct Process        *p_exec_proc;    /* to get back to struct Process */
  208.     
  209.     /* to be able to switch memory lists on the fly, as required when vfork'd
  210.        processes are supposed to allocate memory from their parents pool until
  211.        they detach. */
  212.     struct malloc_data    *u_mdp;
  213.     
  214.     /* data needed for network support */
  215.     struct Library        *u_ixnetbase;
  216.     void            *u_ixnet;
  217.  
  218.     /* ptrace() and kern_sig.c:stopped_process_handler() interface.  */
  219.     struct reg              *u_regs;
  220.     struct fpreg            *u_fpregs;
  221.     int            u_mask_state;
  222.  
  223.     /* strftime() globals */
  224.     size_t            u_gsize;
  225.     char            *u_pt;
  226.     
  227.     /* putenv() global */
  228.     int            u_env_alloced;
  229.     
  230.     /* rand() global */
  231.     u_long            u_rand_next;
  232.     
  233.     /* stuff for stackextend */
  234.     void            *u_tc_splower;    /* original entries of task structure */
  235.     void            *u_tc_spupper;    /* to restore them at exit */
  236.     void            *u_org_lower;    /* original stackborders */
  237.     void            *u_org_upper;
  238.     void            **u_stk_limit;    /* pointer to limit variable */
  239.     unsigned long        u_stk_argbt;    /* Maximum size of arguments */
  240.     struct stackframe    *u_stk_used;    /* used stackframes */
  241.     struct stackframe    *u_stk_spare;    /* spare stackframes */
  242.  
  243.     char u_root_directory[MAXPATHLEN];    /* for chroot() */
  244. };
  245.  
  246. /* flag codes */
  247. #define    SLOAD    0x0000001    /* in core */
  248. #define    SSYS    0x0000002    /* swapper or pager process */
  249. #define    SLOCK    0x0000004    /* process being swapped out */
  250. #define    SSWAP    0x0000008    /* save area flag */
  251. #define    STRC    0x0000010    /* process is being traced */
  252. #define    SWTED    0x0000020    /* parent has been told that this process stopped */
  253. #define    SULOCK    0x0000040    /* user settable lock in core */
  254. #define    SNOCLDSTOP    0x0000080    /* tc_Launch has to take a signal next time */
  255. #define    SFREEA4    0x0000100    /* we allocated memory for a4, free it */
  256. #define    SOMASK    0x0000200    /* restore old mask after taking signal */
  257. #define    SWEXIT    0x0000400    /* working on exiting */
  258. #define    SPHYSIO    0x0000800    /* doing physical i/o (bio.c) */
  259. #define    SVFORK    0x0001000    /* process resulted from vfork() */
  260. #define    SVFDONE    0x0002000    /* another vfork flag */
  261. #define    SNOVM    0x0004000    /* no vm, parent in a vfork() */
  262. #define    SPAGI    0x0008000    /* init data space on demand, from inode */
  263. #define    SSEQL    0x0010000    /* user warned of sequential vm behavior */
  264. #define    SUANOM    0x0020000    /* user warned of random vm behavior */
  265. #define    STIMO    0x0040000    /* timing out during sleep */
  266. #define    SORPHAN    0x0080000    /* process is orphaned (can't be ^Z'ed) */
  267. #define    STRACNG    0x0100000    /* process is tracing another process */
  268. #define    SOWEUPC    0x0200000    /* owe process an addupc() call at next ast */
  269. #define    SSEL    0x0400000    /* selecting; wakeup/waiting danger */
  270. #define    SLOGIN    0x0800000    /* a login process (legit child of init) */
  271.  
  272. /* stat codes */
  273. #define    SSLEEP    1        /* awaiting an event */
  274. #define    SWAIT    2        /* (abandoned state) */
  275. #define    SRUN    3        /* running */
  276. #define    SIDL    4        /* intermediate state in process creation */
  277. #define    SZOMB    5        /* has exited, waiting for parent to pick up status */
  278. #define    SSTOP    6        /* stopped */
  279.  
  280. #endif /* _USER_H */
  281.